<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>EbookDatabase</title>
    <link rel="stylesheet" href="/static/search.css">
</head>

<body>
    <h1>检索结果</h1>
    <p class="search-time">检索时间: {{ search_time | round(2) }} 秒</p>
    <p class="total-records">检索到: {{ total_records }}条内容</p>
    <footer>
        <p class="non-commercial-notice">
            本项目绝不可能盈利，也不会用于任何商业场景(此场景包括论坛币等虚拟货币)，
            如果存在，请不要犹豫，直接举报商家或发帖人。
        </p>
    </footer>

    <div class="button-container">
        <a href="/" class="home-button">回到主页</a>
    </div>

    {% if books %}
    <div class="button-container">
        <button class="select-all-btn">全选</button>
        <button class="deselect-all-btn">全不选</button>
        <button class="copy-selected-btn">复制选中的秒传链接</button>
    </div>
    {% for book in books %}
    <div class="book-container">
        <div class="checkbox-container">
            <label>
                <input type="checkbox" class="copy-checkbox" data-second-pass="{{ book.second_pass_code }}" />
            </label>
        </div>
        <h2 class="book-title">{{ book.title }}</h2>
        <div class="book-details">
            {% if book.author %}<p><strong>作者:</strong> {{ book.author }}</p>{% endif %}
            {% if book.publisher %}<p><strong>出版商:</strong> {{ book.publisher }}</p>{% endif %}
            {% if book.publish_date %}<p><strong>出版日期:</strong> {{ book.publish_date }}</p>{% endif %}
            {% if book.page_count %}<p><strong>页数:</strong> {{ book.page_count }}</p>{% endif %}
            {% if book.ISBN %}<p><strong>ISBN:</strong> {{ book.ISBN }}</p>{% endif %}
            {% if book.SS_code %}<p><strong>SS码:</strong> {{ book.SS_code }}</p>{% endif %}
            {% if book.dxid %}<p><strong>DXID:</strong> {{ book.dxid }}</p>{% endif %}
            <p class="second-pass-code">
                <strong>秒传链接:</strong> <span class="actual-link">{{ book.second_pass_code }}</span>
                <button class="copy-link-btn">复制</button>
            </p>
            {% if book.size %}<p class="file-size"><strong>文件大小:</strong> {{ book.size }}</p>{% endif %}
            {% if book.file_type %}<p><strong>文件类型:</strong> {{ book.file_type }}</p>{% endif %}
        </div>
    </div>
    {% endfor %}
    {% else %}
    <p class="no-results">没有找到匹配的结果。</p>
    {% endif %}


{% if total_pages > 1 %}

<div class="button-container-horizontal">
    <a href="/" class="home-button">回到主页</a>
    <button class="select-all-btn">全选</button>
    <button class="deselect-all-btn">全不选</button>
    <button class="copy-selected-btn">复制选中的秒传链接</button>
</div>

<ul class="pagination">
    <li class="page-item{% if current_page == 1 %} disabled{% endif %}">
        <a class="page-link page-link-js" href="#" data-page="1">首页</a>
    </li>
    {% for i in range(-2, 3) %}
    {% set page_num = current_page + i %}
    {% if page_num > 0 and page_num <= total_pages %}
    <li class="page-item{% if current_page == page_num %} active{% endif %}">
        <a class="page-link page-link-js" href="#" data-page="{{ page_num }}">{{ page_num }}</a>
    </li>
    {% endif %}
    {% endfor %}
    <li class="page-item{% if current_page == total_pages %} disabled{% endif %}">
        <a class="page-link page-link-js" href="#" data-page="{{ total_pages }}">末页</a>
    </li>
</ul>
{% endif %}

{% if books %}
    <div class="jump-container">
        <label for="jump-to-page">跳转到页数:</label>
        <input type="text" id="jump-to-page" placeholder="页数" />
        <button id="jump-button">跳转</button>
    </div>
{% endif %}


<script src="/static/search_js/search_copy.js"></script>
<script src="/static/search_js/search_pagination-controls.js"></script>
<script src="/static/search_js/search_file-size-formatter.js"></script>

</body>
</html>
